#include "video_detect.h"
#include <qboxlayout.h>
#include <qboxlayout.h>
#include <qfileinfo.h>
#include <qmessagebox.h>

video_detect::video_detect(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);
	player = new QMediaPlayer(this);
	//player->setNotifyInterval(2000);	
	video_widget = new QVideoWidget(ui.centralWidget);
	player->setVideoOutput(video_widget);
	QHBoxLayout* hlayout = new QHBoxLayout;
	//QGridLayout* glayout = new QGridLayout(this);
	hlayout->addWidget(video_widget);
	ui.centralWidget->setLayout(hlayout);
	//player->setVideoOutput(ui.video_widget);
}

video_detect::~video_detect()
{
	

}


void video_detect::play_video(QString video_name)
{
	QFileInfo info(video_name);
	if (!info.exists() || player == nullptr)
		QMessageBox::warning(this, "w", "w");

	player->setMedia(QMediaContent(QUrl::fromLocalFile(video_name)));
	
	player->play();
	video_widget->show();
}